package org.jiamandan.com.strategy.impl.tram.listener;

import io.netty.channel.ChannelHandlerContext;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jiamandan.com.constant.BizConstant;
import org.jiamandan.com.constant.JSYConstant;
import org.jiamandan.com.strategy.impl.tram.IJSYDZBasicListener;
import org.springframework.stereotype.Service;


@Service(value = JSYConstant.Service.CMD_JSY_T00004_SERVICE)
@AllArgsConstructor
@Slf4j
public class JSYUpgradeListener implements IJSYDZBasicListener {

    @Override
    public void doExecute(String payload, ChannelHandlerContext client) throws Exception {
        log.info("嘉满电-JSY升级设备应答(CMD = T00004)：" + payload);
        String[] payloads = StringUtils.split(payload, BizConstant.separator1);
        String[] data = StringUtils.split(payloads[1], BizConstant.separator);
        String pileNo = data[1];
        log.info(pileNo);
        log.info(data[0].equals("01")?"升级成功":"升级失败");
    }
}
